package edu.arhs.team1100.worldclass.forms;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Toolkit;
import java.awt.geom.Line2D;

/*
 * Copyright (C) 2014 Eddie
 */
/**
 *
 * @author Eddie
 */
public class FinalsTree extends javax.swing.JFrame {

    /**
     * Creates new form FinalsTree
     */
    public FinalsTree() {
        //setUndecorated(true);
        initComponents();
        //setSize(Toolkit.getDefaultToolkit().getScreenSize());

    }

    public void paint(Graphics g) {
        Graphics2D g2 = (Graphics2D) g;
        int size = 32;
        int h = 30;
        int w = 80;
        int dx = 20;
        int dy = 30;

        for (int j = 0; j <= Math.log(size) / Math.log(2); j++) {
            for (int i = 0; i < size / Math.pow(2, j); i++) {
                g2.draw(new FlipLine(j * w + dx, Math.pow(2, j) * h * i + (Math.pow(2, j - 1) - 1) / 2f * h + dy, j * w + dx, Math.pow(2, j) * h * i + (Math.pow(2, j - 1) - 1) / 2f * h + dy + Math.pow(2, j - 1) * h));
                g2.draw(new FlipLine(j * w + dx, Math.pow(2, j) * i * h + (Math.pow(2, j) - 1) / 2f * h + dy, (j + 1) * w + dx, Math.pow(2, j) * i * h + (Math.pow(2, j) - 1) / 2f * h + dy));
            }
        }


        /* for (int i = 0; i < 24; i++) {
         g2.draw(new Line2D.Float(dx, dy + h * i, dx + w, dy + h * i));
         }

         for (int i = 0; i < 12; i++) {
         g2.draw(new Line2D.Float(dx + w, dy + h * 2 * i, dx + w, dy + h + h * 2 * i));
         g2.draw(new Line2D.Float(dx + w, 2 * i * h + h / 2f + dy, dx + 2 * w, 2 * i * h + h / 2f + dy));
         }

         for (int i = 0; i < 6; i++) {
         g2.draw(new Line2D.Float(dx + 2 * w, 4 * i * h + h / 2f + dy, dx + 2 * w, 4 * i * h + 5 * h / 2f + dy));
         g2.draw(new Line2D.Float(dx + 2 * w, 4 * i * h + 3 * h / 2f + dy, dx + 3 * w, 4 * i * h + 3 * h / 2f + dy));
         }

         for (int i = 0; i < 3; i++) {
         g2.draw(new Line2D.Float(dx + 3 * w, 8 * i * h + 3 * h / 2f + dy, dx + 3 * w, 8 * i * h + 11 * h / 2f + dy));
         g2.draw(new Line2D.Float(dx + 3 * w, 8 * i * h + 7 * h / 2f + dy, dx + 4 * w, 8 * i * h + 7 * h / 2f + dy));
         }
        
         g2.draw(new Line2D.Float(dx + 4 * w, 7*h /2f + dy, dx + 4 * w, 39 * h / 2f + dy));*/
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setBackground(new java.awt.Color(255, 255, 255));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 980, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 911, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
}

class FlipLine extends Line2D.Double {

    public FlipLine(double y0, double x0, double y1, double x1) {
        super(x0, y0, x1, y1);
    }
}
